/* GUI CONVERTED from apapgl1.p (converter v1.76) Thu May  8 19:41:08 2003 */
/* apapgl1.p -  CREATE AP GENERAL LEDGER TRANSACTION CHECKS                  */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/* $Revision: 1.52 $                                            */
/* REVISION: 1.0      LAST MODIFIED: 09/20/86   BY: PML                      */
/* REVISION: 6.0      LAST MODIFIED: 04/26/91   BY: mlv *D595*               */
/*                                   05/31/91   BY: mlv *D667*               */
/* REVISION: 7.0      LAST MODIFIED: 10/28/91   BY: mlv *F028*               */
/* REVISION: 6.0      LAST MODIFIED: 11/06/91   BY: mlv *D915*               */
/* REVISION: 7.0      LAST MODIFIED: 12/13/91   BY: mlv *F074*               */
/*                                              BY: mlv *F200*               */
/*                                   02/21/92   BY: mlv *F224*               */
/*                                   08/07/92   BY: mlv *F836*               */
/* REVISION: 7.4      LAST MODIFIED: 09/13/93   BY: bcm *H110*               */
/*                                   09/22/93   BY: bcm *H136*               */
/*                                   10/19/93   BY: wep *H203*               */
/*                                   02/22/94   BY: pcd *FM34*               */
/*                                   03/28/94   BY: wep *FL75*               */
/*                                   08/10/94   by: pmf *FQ02*               */
/*                                   08/30/94   by: pmf *FQ59*               */
/*                                   09/08/94   BY: bcm *H509*               */
/*                                   11/12/94   BY: str *FT62*               */
/*                                   04/26/95   BY: jzw *F0R3*               */
/*                                   06/21/95   BY: jzw *F0SV*               */
/*                                   10/27/95   by: mys *G1B9*               */
/*                                   11/16/95   by: jzw *H0H8*               */
/*                                   11/14/95   by: mys *F0WQ*               */
/* REVISION: 8.5      LAST MODIFIED: 11/01/95   by: mwd *J053*               */
/*                                   04/25/96   by: jzw *H0KP*               */
/* REVISION: 8.6      LAST MODIFIED: 06/13/96   BY: BJL *K001*               */
/*                                   07/15/96   by: jwk *G1ZW*               */
/*                                   07/18/96   by: *G29H* Sanjay Patil      */
/*                                   11/25/96   by: jzw *K01X*               */
/*                                   03/12/97   by: *K07F* E. Hughart        */
/* REVISION: 8.6      LAST MODIFIED: 07/16/97   BY: *J1VZ* Samir Bavkar      */
/* REVISION: 8.6      LAST MODIFIED: 08/12/97   BY: *J1X9* Samir Bavkar      */
/* REVISION: 8.6      LAST MODIFIED: 11/03/97   BY: *J24H* Irine D'mello     */
/* REVISION: 8.6E     LAST MODIFIED: 03/31/98   BY: *J2D8* Kawal Batra       */
/* REVISION: 8.6E     LAST MODIFIED: 05/09/98   BY: *L00Y* Jeff Wootton      */
/* Pre-86E commented code removed, view in archive revision 1.19             */
/* Commented-out ECO removed, but no header existed *FOWQ*                   */
/* REVISION: 8.6E     LAST MODIFIED: 06/10/98   BY: *H1L5* Dana Tunstall     */
/* REVISION: 8.6E     LAST MODIFIED: 06/25/98   BY: *L034* Russ Witt         */
/* REVISION: 8.6E     LAST MODIFIED: 07/23/98   BY: *L03K* Jeff Wootton      */
/* REVISION: 8.6E     LAST MODIFIED: 09/11/98   BY: *L069* Jeff Wootton      */
/* REVISION: 8.6E     LAST MODIFIED: 09/14/98   BY: *L092* Steve Goeke       */
/* REVISION: 9.0      LAST MODIFIED: 11/30/98   BY: *M00P* Jeff Wootton      */
/* REVISION: 9.0      LAST MODIFIED: 03/10/99   BY: *M0B3* Michael Amaladhas */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan        */
/* REVISION: 9.0      LAST MODIFIED: 03/22/99   BY: *J3CJ* Abbas Hirkani     */
/* REVISION: 9.1      LAST MODIFIED: 05/27/99   BY: *N00D* Adam Harris       */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Brian Compton     */
/* REVISION: 9.1      LAST MODIFIED: 12/28/99   BY: *L0N2* Atul Dhatrak      */
/* REVISION: 9.1      LAST MODIFIED: 04/13/00   BY: *L0VY* Veena Lad         */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0KK* jyn               */
/* REVISION: 9.1      LAST MODIFIED: 09/07/00   BY: *L136* Veena Lad         */
/* REVISION: 9.1      LAST MODIFIED: 09/22/00   BY: *N0W0* Mudit Mehta       */
/* Old ECO marker removed, but no ECO header exists *F0PN*                   */
/* Revision: 1.42   BY: Katie Hilbert  DATE: 04/01/01 ECO: *P002*            */
/* Revision: 1.43   BY: Ed van de Gevel      DATE: 11/09/01 ECO: *N15N*      */
/* Revision: 1.44   BY: Anitha Gopal         DATE: 03/08/02 ECO: *N1C6*      */
/* Revision: 1.45   BY: Rajaneesh S.         DATE: 03/18/02 ECO: *N1DK*      */
/* Revision: 1.46   BY: Ed van de Gevel      DATE: 04/17/02 ECO: *N1GR*      */
/* Revision: 1.47   BY: Paul Donnelly        DATE: 01/27/02 ECO: *N16J*      */
/* Revision: 1.48   BY: Paul Donnelly        DATE: 05/01/02 ECO: *N1HQ*      */
/* Revision: 1.49   BY: Manjusha Inglay      DATE: 07/29/02 ECO: *N1P4*      */
/* Revision: 1.50   BY: Ed van de Gevel      DATE: 08/21/02 ECO: *P0G2*      */
/* Revision: 1.51   BY: Rafal Krzyminski     DATE: 02/10/03 ECO: *P0MN*      */
/* $Revision: 1.52 $  BY: Orawan S.          DATE: 04/28/03 ECO: *P0QL*      */
/*V8:ConvertMode=Maintenance                                                 */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{cxcustom.i "APAPGL1.P"}
{gldydef.i}
{gldynrm.i}

define input parameter reverse like mfc_logical.

define variable tot-vtcurradj  as decimal.
define variable vtclass        as character extent 3.
define variable vtadj          as decimal extent 3.
define variable vtcurradj      as decimal extent 3.
define variable checkref       like ap_ref.
define variable effdate        like glt_effdate.
define variable pmt_curr       like ap_curr.
define variable mstr_desc      like glt_desc.

define new shared variable apply2_rndmthd like rnd_rnd_mthd.

define shared variable base_amt     like ap_amt.
define shared variable aprecid      as recid.
define shared variable vorecid      as recid.
define shared variable jrnl         like glt_ref.
define shared variable undo_all     as logical.
define shared variable trtype       as character.
/* Trtype may be auto, man, void */
define shared variable ref          as character format "x(14)".
define shared variable bkrecid      as recid.
define shared variable ckrecid      as recid.
define shared variable ckdrecid     as recid.
define shared variable apbuffrecid  as recid.
define shared variable base_disc    like ap_amt.
define shared variable gain_amt     like ap_amt.
define shared variable curr_amt     like glt_curr_amt.
define shared variable curr_disc    like glt_curr_amt.
define shared variable base_det_amt like glt_amt.
define shared variable for_curr_amt like ckd_cur_amt.
define shared variable gen_desc  like glt_desc.
define shared variable tot-vtadj     as decimal.
define shared variable batch         like ap_batch.

/*hk-s-024*/ define shared variable hk_amt   like ckd_amt no-undo.

define variable i                as integer no-undo.
define variable vt-date          like ap_effdate no-undo.
define variable disc-pct         as decimal no-undo.
define variable det_ex_rate      like glt_ex_rate no-undo.
define variable det_ex_rate2     like glt_ex_rate2 no-undo.
define variable det_ex_ratetype  like glt_ex_ratetype no-undo.
define variable det_exru_seq     like glt_exru_seq no-undo.
define variable acctcurr         like glt_curr no-undo.
define variable curramt          like glt_curr_amt no-undo.
define variable exrate           like glt_ex_rate no-undo.
define variable exrate2          like glt_ex_rate2 no-undo.
define variable exruseq          like glt_exru_seq no-undo.
define variable cr_ico_amt       like ar_amt no-undo.
define variable cr_ico_curr_amt  like ar_amt no-undo.
define variable pmt_var_acct     like cu_ugain_acct no-undo.
define variable pmt_var_sub      like cu_ugain_sub  no-undo.
define variable pmt_var_cc       like cu_ugain_cc   no-undo.
define variable det_desc         like glt_desc no-undo.
define variable tax_tr_type      like tx2d_tr_type initial "29"
   no-undo.
define variable tax_nbr          like tx2d_ref no-undo.
define variable tax_ref          like tx2d_ref no-undo.
define variable post             like mfc_logical initial true
   no-undo.
define variable disc_acct        like ap_disc_acct no-undo.
define variable disc_sub         like ap_disc_sub no-undo.
define variable disc_cc          like ap_disc_cc no-undo.
define variable use_batch        like ap_batch no-undo.
define variable use_type         like ap_type no-undo.
define variable l_pmt_disc       like tx2_pmt_disc       no-undo.
define variable l_rcpt_tax_point like tx2_rcpt_tax_point no-undo.
define variable l_rnd            like ap_amt             no-undo.
define variable l_chk            like mfc_logical initial no no-undo.
define variable for_curr         like ap_curr no-undo.
define variable mc-error-number  like msg_nbr no-undo.
define variable v_apc_sum_lvl like apc_sum_lvl no-undo.
define variable l_daybooks_in_use like daybooks-in-use no-undo.
define shared buffer apmstr for ap_mstr.
{&APAPGL1-P-TAG1}

for first apc_ctrl
      fields (apc_sum_lvl) no-lock:
end.

for first gl_ctrl
      fields (gl_rnd_mthd) no-lock:
end.

for first ap_mstr where recid(ap_mstr) = aprecid:
end.

for first bk_mstr
   fields (bk_check bk_code bk_curr)
      where recid(bk_mstr) = bkrecid no-lock:
end.

for first ck_mstr where recid(ck_mstr) = ckrecid:
end.

for first ckd_det where recid(ckd_det) = ckdrecid:
end.
{&APAPGL1-P-TAG2}

assign
   det_desc = if ap_mstr.ap_rmk = "" then gen_desc else ap_mstr.ap_rmk
   mstr_desc = det_desc
   det_ex_rate = ck_ex_rate
   det_ex_rate2 = ck_ex_rate2
   det_ex_ratetype = ck_ex_ratetype
   det_exru_seq = ck_exru_seq.
if ckd_voucher <> "" then do:

   for first apmstr where recid(apmstr) = apbuffrecid:
   end.

   for first vo_mstr where recid(vo_mstr) = vorecid:
      assign
         det_ex_rate = vo_ex_rate
         det_ex_rate2 = vo_ex_rate2
         det_ex_ratetype = vo_ex_ratetype
         det_exru_seq = vo_exru_seq
         tax_nbr = vo_ref.
   end.
end.

assign
   tot-vtadj = 0
   tot-vtcurradj= 0.

if available apmstr then do:
   /* GET TAX TOTALS */
   assign
      {&APAPGL1-P-TAG7}
      tax_ref = string(ck_bank, "X(2)") + string(ck_nbr)
      {&APAPGL1-P-TAG8}
      l_chk = no.

   for each tx2d_det
         fields (tx2d_cur_abs_ret_amt tx2d_cur_recov_amt tx2d_nbr
         tx2d_ref tx2d_tax_code tx2d_tr_type)
         where tx2d_ref = tax_ref /* BANK & CHECK */
         and tx2d_nbr = tax_nbr                     /* VOUCHER */
         and tx2d_tr_type = tax_tr_type             /* "29" */
         no-lock:

      /* ACCUMULATE THE PORTION OF THE DISCOUNT-AT-PAYMENT      */
      /* TAX-ADJUSTMENT WHICH SHOULD BE POSTED TO THE           */
      /* AP RECOVERABLE TAX ACCOUNT RATHER THAN TO THE AP TERMS */
      /* DISCOUNT ACCOUNT.                                      */
      /* (EQUIVALENT TO CODE IN APCKRPTX.P)                     */
      tot-vtcurradj = tot-vtcurradj

      /* THE FOLLOWING (NEGATIVE) AMOUNT CREDITS AP RECOVERABLE */
      /* TAX, SO SHOULD BE SUBTRACTED FROM THE AMOUNT WHICH     */
      /* IS CREDITED TO AP TERMS DISCOUNT.                      */
      + tx2d_cur_recov_amt

      /* THE FOLLOWING (POSITIVE) AMOUNT DEBITS AP RETAINED     */
      /* TAX, SO SHOULD BE SUBTRACTED FROM THE AMOUNT WHICH     */
      /* IS DEBITED TO AP TERMS DISCOUNT.                       */
      + tx2d_cur_abs_ret_amt.

      /* ASSUMPTION - FOR A GIVEN VOUCHER tx2_pmt_disc         */
      /* AND tx2_rcpt_tax_point SETTINGS ARE SAME.             */
      if not l_chk then

         for first tx2_mstr
         fields (tx2_pmt_disc tx2_rcpt_tax_point tx2_tax_code)
         where tx2_tax_code = tx2d_tax_code no-lock:

      assign
         l_pmt_disc       = tx2_pmt_disc
         l_rcpt_tax_point = tx2_rcpt_tax_point
         l_chk            = yes.
      end. /* If not l_chk then for */

   end. /* FOR EACH TX2D_DET */

   /* TAX MANAGEMENT ADJUSTMENTS ARE NEGATIVE VALUES */
   if not reverse then
      tot-vtcurradj = - tot-vtcurradj.
   tot-vtadj = tot-vtcurradj.
   if base_curr <> vo_curr then
   do:

   /* IN A MULTI-CURRENCY SETUP WHEN GTM IS OPERATING AS A VAT */
   /* ENVIRONMENT i.e. TAXES ACCRUED AT VOUCHER INSTEAD OF PO  */
   /* RECEIPT AND THE DISCOUNT TAX AT PAYMENT = YES THE        */
   /* VOUCHER EXCHANGE RATE IS USED TO CREDIT THE TAX DISCOUNT */
   /* PORTION AT PAYMENT,ELSE THE CHECK EXCHANGE RATE IS USED. */

      if l_pmt_disc and not l_rcpt_tax_point then
      do:

         /* CONVERT FROM FOREIGN TO BASE CURRENCY */
         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input vo_curr,
              input base_curr,
              input vo_ex_rate,
              input vo_ex_rate2,
              input tot-vtadj,
              input true, /* ROUND */
              output tot-vtadj,
              output mc-error-number)"}.
         if mc-error-number <> 0 then
            run mc_warning.
      end.
      else do:

         /* CONVERT FROM FOREIGN TO BASE CURRENCY */
         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input ck_curr,
              input base_curr,
              input ck_ex_rate,
              input ck_ex_rate2,
              input tot-vtadj,
              input true, /* ROUND */
              output tot-vtadj,
              output mc-error-number)"}.
         if mc-error-number <> 0 then
            run mc_warning.
      end.

   end. /* IF BASE_CURR <> VO_CURR */

   /* GL TRANSACTION DETAIL LINE FOR AP TAX RECOVERABLE ACCOUNT */
   /* SHOULD HAVE PAYMENT OR CHECK VOID EFFECTIVE DATE RATHER   */
   /* THAN VOUCHER EFFECTIVE DATE                               */

   /* CK_VOIDEFF FIELD IS USED TO DIFFERENTIATE WHETHER PROGRAM */
   /* IS CALLED FROM CHECK VOID MAINTENANCE OR OTHER PAYMENT    */
   /* FUNCTIONS                                                 */

   if ck_mstr.ck_voideff = ? then
   assign
      vt-date = ap_mstr.ap_effdate.
   else
   assign
      vt-date = ck_mstr.ck_voideff.

end. /* IF available apmstr */
else
   vt-date = ap_mstr.ap_effdate. /*check*/

assign
   curr_disc = curr_disc - tot-vtcurradj
   base_disc = curr_disc.

/* INSURE THAT SUM base_disc AND tot_vtadj DOES NOT EXCEED  */
/* THE TOTAL BASE DISCOUNT CAUSING A ROUNDING ERROR.        */

if base_curr <> ck_curr
   or (ckd_voucher <> "" and apmstr.ap_curr <> base_curr) then do:

      /* CONVERT FROM FOREIGN TO BASE CURRENCY */
      {gprunp.i "mcpl" "p" "mc-curr-conv"
         "(input ck_curr,
           input base_curr,
           input ck_ex_rate,
           input ck_ex_rate2,
           input (curr_disc + tot-vtcurradj),
           input true, /* ROUND */
           output base_disc,
           output mc-error-number)"}.
      if mc-error-number <> 0 then
            run mc_warning.

      {gprunp.i "mcpl" "p" "mc-curr-rnd"
         "(input-output base_disc,
           input gl_rnd_mthd,
           output mc-error-number)"}.
      if mc-error-number <> 0 then
            run mc_warning.

      l_rnd  = (if l_pmt_disc and not l_rcpt_tax_point then
               (tot-vtadj * vo_ex_rate / vo_ex_rate2
               * ck_ex_rate2 / ck_ex_rate)
               else tot-vtadj).

      {gprunp.i "mcpl" "p" "mc-curr-rnd"
         "(input-output l_rnd,
           input gl_rnd_mthd,
           output mc-error-number)"}.
      if mc-error-number <> 0 then
         run mc_warning.

      base_disc = base_disc - l_rnd.

end. /* IF base_curr <> ck_curr */

assign
   gain_amt = base_det_amt - base_amt - base_disc - tot-vtadj
   checkref = if trtype = "auto"
   {&APAPGL1-P-TAG9}
   then string(ck_bank,"x(2)") + string(ck_nbr)
   {&APAPGL1-P-TAG10}
              else ap_mstr.ap_ref
   pmt_curr = ap_mstr.ap_curr.

if ck_voideff <> ? then
assign
   effdate = ck_voideff
   use_batch = batch
   use_type  = "CV".
else
assign
   effdate = ap_mstr.ap_effdate
   use_batch = ap_mstr.ap_batch
   use_type = ap_mstr.ap_type.

{&APAPGL1-P-TAG15}
if gain_amt <> 0 and ckd_voucher <> ""
then do:
   /* IF BASE PMT FOREIGN VOUCHER, GET VAR ACCOUNT FROM VOUCHER'S  */
   /* BANK OR FIRST WHERE VO_CURR MATCHES (pmt manual ck function) */
   if ck_curr = base_curr
      and apmstr.ap_curr <> base_curr then do:

      /* GET REALIZED GAIN/LOSS ACCOUNTS FROM PAYMENT CURRENCY */
      for first cu_mstr
            where cu_curr = apmstr.ap_curr
            no-lock:
      end.
{&APAPGL1-P-TAG13}
      assign
         pmt_var_acct = (if not available cu_mstr then ""
                         else if gain_amt > 0 then
                         if not reverse then cu_rgain_acct
                         else cu_rloss_acct
                         else if gain_amt < 0 then
                         if not reverse then cu_rloss_acct
                         else cu_rgain_acct
                         else "")
         pmt_var_sub  = (if not available cu_mstr then ""
                         else if gain_amt > 0 then
                         if not reverse then cu_rgain_sub
                         else cu_rloss_sub
                         else if gain_amt < 0 then
                         if not reverse then cu_rloss_sub
                         else cu_rgain_sub
                         else "")
         pmt_var_cc   = (if not available cu_mstr then ""
                         else if gain_amt > 0 then
                         if not reverse then cu_rgain_cc
                         else cu_rloss_cc
                         else if gain_amt < 0 then
                         if not reverse then cu_rloss_cc
                         else cu_rgain_cc
                         else "").
   end.

   /* IF BASE BANK AND FOREIGN PAYMENT AND FOREIGN INVOICE       */
   /* THEN GET GAIN/LOSS ACCT FROM FIRST BANK WHERE CURR MATCHES */
   else do:

      /* GET REALIZED GAIN/LOSS ACCOUNTS FROM PAYMENT CURRENCY */
      for first cu_mstr
            where cu_curr = ap_mstr.ap_curr
            no-lock:
      end.
{&APAPGL1-P-TAG14}
      assign
         pmt_var_acct = (if not available cu_mstr then ""
                         else if gain_amt > 0 then
                         if not reverse then cu_rgain_acct
                         else cu_rloss_acct
                         else if gain_amt < 0 then
                         if not reverse then cu_rloss_acct
                         else cu_rgain_acct
                         else "")
         pmt_var_sub  = (if not available cu_mstr then ""
                         else if gain_amt > 0 then
                         if not reverse then cu_rgain_sub
                         else cu_rloss_sub
                         else if gain_amt < 0 then
                         if not reverse then cu_rloss_sub
                         else cu_rgain_sub
                         else "")
         pmt_var_cc   = (if not available cu_mstr then ""
                         else if gain_amt > 0 then
                         if not reverse then cu_rgain_cc
                         else cu_rloss_cc
                         else if gain_amt < 0 then
                         if not reverse then cu_rloss_cc
                         else cu_rgain_cc
                         else "").
   end.
end. /* IF GAIN_AMT <> 0 */

/* IF BASE CURRENCY TRANSACTION AGAINST A FOREIGN CURRENCY */
/* VOUCHER, THEN PASS TO GPGL.I CURRENCY AMOUNTS IN BASE   */
/* CURRENCY. ALSO, PASS CURRENCY AMOUNT IN FOREIGN FOR AP  */
/* ACCOUNT DENOMINATED IN FOREIGN CURRENCY                 */
{&APAPGL1-P-TAG3}

if ckd_voucher <> ""
   and apmstr.ap_curr <> ap_mstr.ap_curr then
{&APAPGL1-P-TAG4}
assign
   for_curr_amt  = curr_amt + curr_disc + tot-vtcurradj
   for_curr      = apmstr.ap_curr
   curr_amt      = base_amt
   curr_disc     = base_disc
   tot-vtcurradj = tot-vtadj.

if available apmstr then
assign
   disc_acct = apmstr.ap_disc_acct
   disc_sub = apmstr.ap_disc_sub
   disc_cc = apmstr.ap_disc_cc.
else
assign
   disc_acct = ap_mstr.ap_disc_acct
   disc_sub = ap_mstr.ap_disc_sub
   disc_cc = ap_mstr.ap_disc_cc.

if daybooks-in-use then do:
   if ap_mstr.ap_dy_code > "" and use_type <> "CV"
   then
      dft-daybook = ap_mstr.ap_dy_code.

   for first dy_mstr
         fields (dy_desc dy_dy_code)
         where dy_dy_code = dft-daybook no-lock:
   end.
   /* DELAY THE LOCKING OF nr_mstr AND GENERATION OF SEQUENCE NUMBER */
   assign
      daybook-desc      = if available dy_mstr
                          then
                             dy_desc
                          else
                             gen_desc
      l_daybooks_in_use = daybooks-in-use
      daybooks-in-use   = no
      mstr_desc         = daybook-desc
      gen_desc          = daybook-desc.

{&APAPGL1-P-TAG16}
end. /* IF DAYBOOKS IN USE */

/* CREATE ALL GLT_DET RECORDS FOR THIS LINE */
{&APAPGL1-P-TAG5}

/* DELETED PARAMETER h-nrm                  */
{gprunp.i "xxapglpl" "p" "apgl-create-all-glt"
           "(input base_disc,
             input gain_amt,
             input curr_amt,
             input curr_disc,
             input ckd_det.ckd_acct, /* lineacct */
             input ckd_det.ckd_sub, /* linesub */
             input ckd_det.ckd_cc, /* linecc */
             input ckd_det.ckd_project, /* lineproject */
             input checkref,
             input pmt_curr,
             input tot-vtadj,
             input-output effdate,
             input use_batch,
             input ap_mstr.ap_acct, /* mstracct */
             input ap_mstr.ap_sub, /* mstrsub */
             input ap_mstr.ap_cc, /* mstrcc */
             input bk_mstr.bk_entity, /* crentity */
             input (if available apmstr then apmstr.ap_entity
            else ap_mstr.ap_entity), /* drentity */
             input use_type,
             input pmt_var_acct,
             input pmt_var_sub,
             input pmt_var_cc,
             input ap_mstr.ap_vend,
             input ck_mstr.ck_ex_rate,
             input ck_mstr.ck_ex_rate2,
             input ck_mstr.ck_ex_ratetype,
             input ck_mstr.ck_exru_seq,
             input for_curr,
             input for_curr_amt,
             input dft-daybook,
             input daybook-desc,
             input disc_acct,
             input disc_sub,
             input disc_cc,
             input tot-vtcurradj,
             input base_amt,
             input base_det_amt,
             input det_ex_rate,
             input det_ex_rate2,
             input-output jrnl,
             output ref,
             input mstr_desc,
             input gen_desc,
             input det_desc,
             input vtadj[1],
             input vtadj[2],
             input vtadj[3],
             input vtcurradj[1],
             input vtcurradj[2],
             input vtcurradj[3],
             input vtclass[1],
             input vtclass[2],
             input vtclass[3],
             input vt-date,
             input daybooks-in-use,
             input-output nrm-seq-num,
/*hk-s-024*/ input hk_amt,
/*hk-s-024*/ input ap_mstr.ap_user1,
/*hk-s-024*/ input reverse             
             )"}.
{&APAPGL1-P-TAG6}

assign v_apc_sum_lvl = apc_sum_lvl.
if v_apc_sum_lvl = 1 then assign v_apc_sum_lvl = 2.
else if v_apc_sum_lvl = 2 then assign v_apc_sum_lvl = 1.
/* ADDED SECOND EXCHANGE RATE, TYPE, SEQUENCE */
/* CHANGED "not apc_gl_sum" TO "v_apc_sum_lvl" */
{&APAPGL1-P-TAG11}
{gprun.i ""txglpost.p"" "(input tax_tr_type   /* TRANSACTION TYPE */,
                          input tax_ref             /* REFERENCE */,
                          input tax_nbr                /* NUMBER */,
                          input pmt_curr  /* TRANSACTION CURRENCY*/,
                          input ref       /* GL REFERENCE NUMBER */,
                          input vt-date        /* EFFECTIVE DATE */,
                          input det_ex_rate     /* EXCHANGE RATE */,
                          input det_ex_rate2,
                          input det_ex_ratetype,
                          input det_exru_seq,
                          input use_batch        /* BATCH */,
                          input 'AP'                   /* MODULE */,
                          input gen_desc   /* TRANS. DESCRIPTION */,
                          input post                     /* POST */,
                          input v_apc_sum_lvl      /* SUMM LEVEL */,
                          input false             /* AUDIT TRAIL */,
                          input false        /* REPORT IN DETAIL */,
                          input ''                     /* PROJECT*/,
                          input use_type     /* TYPE OF DOCUMENT */,
                          input ap_mstr.ap_vend       /* ADDRESS */,
                          input 'CHECK'        /* GLTW_WKFL TYPE */,
                          input if reverse then -1 else 1
                                 /* POSTING SIGN */
                         )" }
/*GUI*/ if global-beam-me-up then undo, leave.


{&APAPGL1-P-TAG12}
/* RESET the VARIABLE daybooks-in-use */
daybooks-in-use = l_daybooks_in_use .
undo_all = no.

/*------------------------------------------------------------------*/

/*------------------------------------------------------------------*/

PROCEDURE mc_warning:

   {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}

END PROCEDURE.
